package  
{
	import net.flashpunk.Entity;
	import net.flashpunk.FP;
	
	/**
	 * ...
	 * @author Donatello
	 */
	public class Tank extends Entity
	{		
		protected var axisX:Number;// 1 o -1 
		protected var axisY:Number;// 1 o -1
		protected var speed:Number = 4;
		
		protected var px:Number;
		protected var py:Number;
		
		protected var antX:Number;
		protected var antY:Number;
		
		protected var colisiona:Boolean = false;
		
		public function Tank(fx:Number,fy:Number) 
		{
			x = fx;
			y = fy;
			
			axisX = 0;
			axisY = -1;
			
			type = "Tank";
		}
		
		public function move(fx:Number,fy:Number):void
		{
			axisX = fx;
			axisY = fy;
			
			if (!colisiona)
			{
				antX = x;
				antY = y;
				
				if ((x + fx * speed) > 45 &&  (x + fx * speed)+52 < 703)
					x += fx *speed;
				
				if ((y + fy * speed) > 18 &&  (y + fy * speed)+52 < 582)
					y += fy * speed;
			}
			else
			{
				x = antX;
				y = antY;
			}
		}
		
		public function shoot():void
		{
			if (axisX == -1) { px = 0; py = 24; }
			if (axisX == 1) { px = 52; py = 24; }
			if (axisY == -1) { px = 24; py = 0; }
			if (axisY == 1) { px = 24; py = 52; }
			
			FP.world.add(new Bullet(x + px, y + py, axisX, axisY));
			
		}

	}
}